<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.yaodian100.mall.member.util.UserData"%>
<%@page import="com.yaodian100.ec.member.entity.Member"%>
<%@page import="com.yaodian100.ec.member.service.MemberService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="com.yaodian100.core.common.dao.impl.CommonCriteria"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DecimalFormat"%>
<%@page import="java.text.NumberFormat"%>
<%@page import="com.yaodian100.ec.member.entity.Balance"%>
<%@page import="java.util.List"%>
<%@page import="com.yaodian100.ec.member.entity.ViewWishList"%>
<%@page import="com.yaodian100.ec.coupon.service.CouponService"%>
<%@page import="com.yaodian100.ec.announcement.entity.Announcement"%>
<%@page import="org.apache.commons.lang.xwork.StringUtils"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="frontContextPath" value='<%=ServerValue.getFrontContextPath()%>'/>
<html>
<head>
</head>
<body>
<%
CouponService couponService = (CouponService)WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()).getBean("couponService");
Member member = (Member)request.getAttribute("member");
DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
NumberFormat formatter = new DecimalFormat("#####0.0#");
Balance balance = member.getBalance();
@SuppressWarnings("unchecked")
List<ViewWishList> cList = (List)request.getAttribute("viewWishList");
ViewWishList vwList;
@SuppressWarnings("unchecked")
List<Announcement> annList = (List)request.getAttribute("annList");
Announcement announcement;
%>
  <div id="main" class="member-index">
  <!-- content start -->

    <div class="content mb-j-index">
  	<div class="m-info">
  	<h4>
  		<%if(null!=member.getLastLoginTime()){ %>
    		<span>上一次登录：<%=dateformat.format(member.getLastLoginTime())%></span>您好，<%=member.getLoginId().length()>20?member.getName():member.getLoginId()%>  欢迎回来！
    	<%}else{ %>
    		<span>上一次登录：无</span>您好，<%=member.getLoginId().length()>20?member.getName():member.getLoginId() %>  欢迎回来！
    	<%} %>
    <c-rt:if test ="${'3' != member.crmUpdate}"><var>( <a href="${frontContextPath}/member/modifydata.do">完善并验证个人信息</a>，${completeInfoBonus} 积分等你拿。)</var></c-rt:if>
    </h4>
    </div>
    
  <div class="content mb-j-index">
    <!-- 456end -->
      <div class="mb-index-box">
	    <h2>我最近的订单</h2>

		<div class="mb-index-show">	
       	  <div class="mb-infolist">
       	<p class="a-arrow"><a href="${frontContextPath}/member/myOrder/showOrders.do?t=Y&p=1">需支付的订单</a>：<b><%=balance.getOrderToPay()==null?"0":balance.getOrderToPay().toBigInteger() %></b> 笔</p>
           <p class="a-arrow">查看<a href="${frontContextPath}/member/myOrder/showOrders.do?t=T&p=1">最近的订单</a></p>
           <p class="a-arrow"><a href="${frontContextPath}/member/mycomment/mycomment.do?p=1">可评价的商品</a>：<b>${numOrderCommet}</b> 笔</p>
       	  </div>
        </div>

      </div>
    <!-- 456end -->
       <!-- 456end -->
      <div class="mb-index-box">
		    <h2>帐户管理</h2>
			<div class="mb-index-show">	
            	<div class="mb-infolist-half">
            	<%if("nonmember".equalsIgnoreCase(member.getApplySource())){ %>	
				<p class="icon-mypoint"><a href="javascript:;" onclick='checkLoginMember("${frontContextPath}/member/myBonus/tomybonus.do");'>我的积分</a>：<b> ￥<%=balance.getBonusBalance()%></b></p>
				<p class="icon-mycoupon"><a href="javascript:;" onclick='checkLoginMember("${frontContextPath}/member/myCoupon/tomycoupon.do");'>可用礼券</a>： <b>￥<%=couponService.getFreeItemsTotal(member.getMemberId())%>.0</b></p>
				<%}else{ %>	
				<p class="icon-mypoint"><a href="${frontContextPath}/member/myBonus/tomybonus.do">我的积分</a>：<b> <%=balance.getBonusBalance()%></b></p>
				<p class="icon-mycoupon"><a href="${frontContextPath}/member/myCoupon/tomycoupon.do">可用礼券</a>： <b>￥<%=couponService.getFreeItemsTotal(member.getMemberId())%>.0</b></p>
				<%} %>
                </div>
                <div class="mb-infolist-half">
                <p class="icon-mybank"><a href="${frontContextPath}/member/myBank/myBank.do">我的账户余额</a>： <b> ￥<%=formatter.format(balance.getVirtualBalance())%> </b></p>
                <p class="icon-mycard"><a href="${frontContextPath}/member/myGiftcard/tomygiftcard.do">可用礼品卡</a>： <b> ￥<%=formatter.format(balance.getGiftcardBalance())%> </b></p>
                </div>
            </div>
      </div>
  	   <!-- 456end -->

       <!-- 456end -->
     <div class="mb-index-box">
    <h2>商品问与答</h2>
			<div class="mb-index-show2">	
            	<div class="mb-infolist">
            	<%if("nonmember".equalsIgnoreCase(member.getApplySource())){ %>	
				<p class="a-arrow"><a href="javascript:;" onclick='checkLoginMember("${frontContextPath}/member/product/qaa.do?answered=true&orderByAnswerDate=desc");'>已回答的商品提问</a>：两周内 <b><%=balance.getRepliedProductQuestion()==null?"0":balance.getRepliedProductQuestion().toBigInteger() %></b> 笔</p>
                <p class="a-arrow"><a href="javascript:;" onclick='checkLoginMember("${frontContextPath}/member/product/qaa.do?answered=false&orderByQuestionDate=desc");'>发问中的商品提问</a>：<b><%=balance.getAskedProductQuestion()==null?"0":balance.getAskedProductQuestion().toBigInteger() %></b> 笔</p>
				<%}else{ %>	
				<p class="a-arrow"><a href="${frontContextPath}/member/product/qaa.do?answered=true">已回答的商品提问</a>：两周内 <b><%=balance.getRepliedProductQuestion()==null?"0":balance.getRepliedProductQuestion().toBigInteger() %></b> 笔</p>
                <p class="a-arrow"><a href="${frontContextPath}/member/product/qaa.do?answered=false">发问中的商品提问</a>：<b><%=balance.getAskedProductQuestion()==null?"0":balance.getAskedProductQuestion().toBigInteger() %></b> 笔</p>
				<%} %>
              </div>
            </div>
      </div>
  	   <!-- 456end -->
       <!-- 456end -->

      <div class="mb-index-box">
	    <h2>客服问与答</h2>
		<div class="mb-index-show2">	
            	<div class="mb-infolist">
            	  <p class="a-arrow"><a href="${frontContextPath}/member/cs/qaa.do?answered=true">已回答的客服问答</a>：两周内 <b><%=balance.getRepliedCRM()==null?"0":balance.getRepliedCRM().toBigInteger() %></b> 笔</p>
                  <p class="a-arrow"><a href="${frontContextPath}/member/cs/qaa.do?answered=false">发问中的客服问答</a>：<b><%=balance.getAskedCRM()==null?"0":balance.getAskedCRM().toBigInteger() %></b> 笔</p>
                </div>
        </div>
      </div>
  	   <!-- 456end -->
       <!-- 456end -->
      <div class="mb-index-box">
	    <h2>收藏商品</h2>
  <div class="mb-index-show3">	
         <div class="mb-photolist">
       	      <div class="pd-c">
       	      <%if(cList.size()==0){%><p>目前没有收藏任何商品，快把喜欢的商品加入收藏盒吧！</p><%} %>
       	      <%for(int i = 0 ; i < cList.size(); i++){ 
       	      	vwList = cList.get(i);%>
       	      	<a target=_blank href="<%=vwList.getFullUrl() %>"><img src="/PImg/<%=vwList.getProductId().substring(0,4) %>/<%=vwList.getProductId()%>/<%=vwList.getProductId()%>_m75.jpg" alt="" width="75" height="75" onError="this.src='/PImg/blank_75.gif'" /></a>
       	      <% } %>
              </div>
              <%if(cList.size()!=0){%><div class="a-function"><a href="${frontContextPath}/member/myCollection/toproductc.do">&gt;&gt;更多收藏商品</a></div><%} %>
        </div>
        </div>
      </div>

      <div class=mb-index-box>
        <H2>会员讯息</H2>
        <div class=mb-index-show4>
          <div class=mb-infolist>
          
            <ul style="LINE-HEIGHT: 200%">
              <s:if test="%{memberMessageList == null || memberMessageList.size() <= 0}">
                <li>目前没有会员讯息 </li>
              </s:if>
              <s:else>
                <s:iterator value="%{memberMessageList}" var="memberMessage" status="stat" >
                  <s:if test="#stat.count <= 3">
                    <li>
                                                    ．
                    <c-rt:choose>
                      <c-rt:when test="${ empty memberMessage.targetURL }">
                        <s:if test="%{ #memberMessage.highlight}">
                          <a href="${frontContextPath}/announcement/viewMemberMessage.do?annId=${ memberMessage.id }" target="_blank" class="txt-rd" >${memberMessage.subject}</a>
                        </s:if>
                        <s:else>
                          <a href="${frontContextPath}/announcement/viewMemberMessage.do?annId=${ memberMessage.id }" target="_blank" >${memberMessage.subject}</a>
                        </s:else>
                        </c-rt:when>
                        <c-rt:otherwise>
                        <s:if test="%{ #memberMessage.highlight}">
                          <a href="${memberMessage.targetURL}" target="_blank" class="txt-rd" >${memberMessage.subject}</a>
                        </s:if>
                        <s:else>
                          <a href="${memberMessage.targetURL}" target="_blank" >${memberMessage.subject}</a>
                        </s:else>
                      </c-rt:otherwise>
                    </c-rt:choose>
                    </li>
                  </s:if>
                </s:iterator>
              </s:else>
            </ul>
            
            <s:if test="%{memberMessageList != null && memberMessageList.size() > 0}">
              <div class=a-function>
                <a href="${frontContextPath}/announcement/listAllMemberMessage.do">&gt;&gt;更多</a>
              </div>
            </s:if>
            
          </div>
        </div>
      </div>
      
  	   <!-- 456end -->
       <!-- 456end -->
      <div class="mb-index-box">

	    <h2>最新快报</h2>
		<div class="mb-index-show5">	
            	<div class="mb-infolist">
        			<ul style="line-height:200%">
        				<%for(int i = 0 ; i < annList.size() ; i++){ 
        					announcement = annList.get(i);
        				%>
        				<li>．
						<%if(StringUtils.isNotBlank(announcement.getTargetURL())){ %>
						<a href="<%=announcement.getTargetURL()%>" target="_blank"<%="Y".equals(announcement.getIsHighlight())?" class=\"txt-rd\"":"" %>><%=announcement.getSubject() %></a>
						<%}else{ %>	
						<a href="${frontContextPath}/announcement/viewv2.do?annId=<%=announcement.getId()%>" target="_blank"<%="Y".equals(announcement.getIsHighlight())?" class=\"txt-rd\"":"" %>><%=announcement.getSubject()%></a>
						<%} %>
						</li>
        				<%} %>
       			    </ul>
                </div>
                <div class="a-function"><a href="${frontContextPath}/announcement/listAll.do">&gt;&gt;更多快报与优惠活动</a></div>
        </div>
      </div>
      <img src="/images/none.gif" class="c-f" />
  	  <!-- 456end -->
  </div>
  <!-- content end -->
  </div>
</div>
<c-rt:if test ="${'Y' eq showMsg}">
<script language="javascript">
	$().ready(function(){
		$("#msg_dialog").dialog({
			bgiframe : true,
			width : 480,
			height : 'auto',
			resizable : false,
			modal : true
		});
		$("#msg_dialog_close").click(function(){
			$("#msg_dialog").dialog('close');
		});
	});
</script>
<!-- START 完善个人信息提示弹窗 -->
<div id="msg_dialog" title="温馨提示" class="member-reg-alert-ok poise" style="display:none">
  <div>
  	<h3>完善个人信息并完成验证后，获得 <strong class="txt-rd">${completeInfoBonus}</strong> 积分！</h3>
    <dfn>获得的积分将可以作为现金抵用订单金额，赶快行动喔......</dfn>
  </div>
  <span class="btn-cradle">
      <a href="${frontContextPath}/member/modifydata.do" class="btn-mid">好，这就去</a>
      <a href="javascript:;" id="msg_dialog_close" class="btn-mid opacity">还是以后再说吧</a>
  </span>
</div>
<!-- START 完善个人信息提示弹窗 -->
</c-rt:if>
</body>
</html>